using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class SpecialHandlingCodeAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public SpecialHandlingCodeAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.User;
						tableVersionTypes[HL7Version.v26] = HL7TableType.User;
						tableVersionTypes[HL7Version.v27] = HL7TableType.User;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v24] = new string[]{"PRTL","CFRZ","CATM","CREF","CAMB","C37"};
						validVersionCodes[HL7Version.v25] = new string[]{"C37","AMB","CAMB","REF","CREF","FRZ","CFRZ","DFRZ","UFRZ","NTR","PRTL","CATM","DRY","PSO","PSA","UPR","MTLF"};
						validVersionCodes[HL7Version.v251] = new string[]{"C37","AMB","CAMB","REF","CREF","FRZ","CFRZ","DFRZ","UFRZ","NTR","PRTL","CATM","DRY","PSO","PSA","UPR","MTLF"};
						validVersionCodes[HL7Version.v26] = new string[]{"C37","AMB","CAMB","REF","CREF","FRZ","CFRZ","DFRZ","UFRZ","NTR","PRTL","CATM","DRY","PSO","PSA","UPR","MTLF"};
						validVersionCodes[HL7Version.v27] = new string[]{"C37","AMB","CAMB","REF","CREF","FRZ","CFRZ","DFRZ","UFRZ","NTR","PRTL","CATM","DRY","PSO","PSA","UPR","MTLF"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v24] = new string[]{"Protect from light","Critical Frozen","Critical do not expose to atmosphere - Do not uncap","Critical refrigerated","Critical ambient temperature","Critical maintain at 37C (e.g., cryoglobulin specimen"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Body temperature","Ambient temperature","Critical ambient temperature","Refrigerated temperature","Critical refrigerated temperature","Frozen temperature","Critical frozen temperature","Deep frozen","Ultra frozen","Liquid nitrogen","Protect from light","Protect from air","Dry","No shock","Do not shake","Upright","Metal Free"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Body temperature","Ambient temperature","Critical ambient temperature","Refrigerated temperature","Critical refrigerated temperature","Frozen temperature","Critical frozen temperature","Deep frozen","Ultra frozen","Liquid nitrogen","Protect from light","Protect from air","Dry","No shock","Do not shake","Upright","Metal Free"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Body temperature","Ambient temperature","Critical ambient temperature","Refrigerated temperature","Critical refrigerated temperature","Frozen temperature","Critical frozen temperature","Deep frozen","Ultra frozen","Liquid nitrogen","Protect from light","Protect from air","Dry","No shock","Do not shake","Upright","Metal Free"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Body temperature","Ambient temperature","Critical ambient temperature","Refrigerated temperature","Critical refrigerated temperature","Frozen temperature","Critical frozen temperature","Deep frozen","Ultra frozen","Liquid nitrogen","Protect from light","Protect from air","Dry","No shock","Do not shake","Upright","Metal Free"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
